package com.easylinkin.linkappapi.ruleengine.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easylinkin.linkappapi.device.entity.Device;
import com.easylinkin.linkappapi.deviceservice.entity.DeviceServices;
import com.easylinkin.linkappapi.linkage.entity.LinkageConfigRelateServiceParm;
import com.easylinkin.linkappapi.ruleengine.entity.RuleExecution;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 执行器 服务类
 * </p>
 *
 * @author TongJie
 * @since 2020-08-24
 */
public interface RuleExecutionService extends IService<RuleExecution> {

    void add(RuleExecution ruleExecution);

    List<RuleExecution> getRuleExecutions(RuleExecution ruleExecution);

    IPage<RuleExecution> getRuleExecutions(Page page, RuleExecution ruleExecution);


    List<RuleExecution> getRuleExecutionDetails(RuleExecution ruleExecution1);

    List<DeviceServices> getDeviceServiceListFromFlat(List<LinkageConfigRelateServiceParm> linkageConfigRelateServiceParmList);

//    void updateRuleExecution(RuleExecution ruleExecution);

    void saveLinkageServiceParams(String ruleExecutionId, List<LinkageConfigRelateServiceParm> linkageConfigRelateServiceParms);

    /**
     * 产生联动
     */
    void generateLinkage(RuleExecution ruleExecution);

    void deleteBatch(List<RuleExecution> ruleExecutionList);

//    void checkGenerateLinkage(Device device);

    /**
     * 查找 执行器以及执行器关联的下行设备 ，查找条件：规则引擎id列表 ；将规则引擎以及 告警模板一起查出来
     *
     * @param ruleEngineIds 规则引擎id列表
     */
    List<RuleExecution> getRuleExecutionWithLinkageConfigRefDownDeviceList(Set<String> ruleEngineIds);

    Map<String, Object> getSendDownParameter(List<LinkageConfigRelateServiceParm> linkageConfigRelateServiceParmList);


    /**
     * 执行器 根据引擎id列表，相关执行器并执行
     *
     * @param ruleEngineIds 规则引擎id列表
     * @param device 设备
     */
    void execute(Set<String> ruleEngineIds, Device device);
}
